home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ADA / GNAT / !gcc / adainc / 4 / ads / i-os2thr < prev    next >
Text File  |  1996-02-12  |  7KB  |  175 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --             I N T E R F A C E S . O S 2 L I B . T H R E A D S            --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.9 $                             --
  10. --                                                                          --
  11. --        Copyright (C) 1993,1994,1995 Free Software Foundation, Inc.       --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNAT was originally developed  by the GNAT team at  New York University. --
  32. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  33. --                                                                          --
  34. ------------------------------------------------------------------------------
  35.  
  36. with Interfaces.C;
  37.  
  38. package Interfaces.OS2Lib.Threads is
  39. pragma Preelaborate (Threads);
  40.  
  41.    package IC renames Interfaces.C;
  42.  
  43.    type PID is new IC.unsigned_long;
  44.    type PPID is access all PID;
  45.    --  Process ID, and pointer to process ID
  46.  
  47.    type TID is new IC.unsigned_long;
  48.    type PTID is access all TID;
  49.    --  Thread ID, and pointer to thread ID
  50.  
  51.    -------------------------------------------------------------
  52.    -- Thread Creation, Activation, Suspension And Termination --
  53.    -------------------------------------------------------------
  54.  
  55.    --  Note: <bsedos.h> defines the "Informations" and "param" parameter below
  56.    --  as a ULONG, but everyone knows that in general an address will be passed
  57.    --  to it. We declared it here with type PVOID (which it should have had)
  58.    --  because Ada is a bit more sensitive to mixing integers and addresses.
  59.  
  60.    type PFNTHREAD is access procedure (Informations : System.Address);
  61.    --  TBSL should use PVOID instead of Address as per above node ???
  62.  
  63.    function DosCreateThread
  64.      (F_ptid  : PTID;
  65.       pfn     : PFNTHREAD;
  66.       param   : PVOID;
  67.       flag    : ULONG;
  68.       cbStack : ULONG)
  69.       return    APIRET;
  70.    pragma Import (C, DosCreateThread, "DosCreateThread");
  71.  
  72.    Block_child     : constant := 1;
  73.    No_Block_child  : constant := 0;
  74.    Commit_stack    : constant := 2;
  75.    No_Commit_stack : constant := 0;
  76.    --  Values for "flag" parameter in DosCreateThread call
  77.  
  78.    procedure DosExit (Action : ULONG; Result : ULONG);
  79.    pragma Import (C, DosExit, "DosExit");
  80.  
  81.    EXIT_THREAD  : constant := 0;
  82.    EXIT_PROCESS : constant := 1;
  83.    --  Values for "Action" parameter in Dos_Exit call
  84.  
  85.    function DosResumeThread (Id : TID) return APIRET;
  86.    pragma Import (C, DosResumeThread, "DosResumeThread");
  87.  
  88.    function DosSuspendThread (Id : TID) return APIRET;
  89.    pragma Import (C, DosSuspendThread, "DosSuspendThread");
  90.  
  91.    procedure DosWaitThread (Thread_Ptr : PTID; Option : ULONG);
  92.    pragma Import (C, DosWaitThread, "DosWaitThread");
  93.  
  94.    DCWW_WAIT   : constant := 0;
  95.    DCWW_NOWAIT : constant := 1;
  96.    --  Values for "Option" parameter in DosWaitThread call
  97.  
  98.    ---------------------------------------------------
  99.    -- Accessing properties of Threads and Processes --
  100.    ---------------------------------------------------
  101.  
  102.    --  Structures translated from BSETIB.H
  103.  
  104.    --  Thread Information Block (TIB)
  105.    --  Need documentation clarifying distinction between TIB, TIB2 ???
  106.  
  107.    type TIB2 is record
  108.       tib2_ultid        : ULONG;  -- Thread I.D.
  109.       tib2_ulpri        : ULONG;  -- Thread priority
  110.       tib2_version      : ULONG;  -- Version number for this structure
  111.       tib2_usMCCount    : USHORT; -- Must Complete count
  112.       tib2_fMCForceFlag : USHORT; -- Must Complete force flag
  113.    end record;
  114.  
  115.    type PTIB2 is access all TIB2;
  116.  
  117.    --  Thread Information Block (TIB)
  118.  
  119.    type TIB is record
  120.       tib_pexchain      : PVOID;  -- Head of exception handler chain
  121.       tib_pstack        : PVOID;  -- Pointer to base of stack
  122.       tib_pstacklimit   : PVOID;  -- Pointer to end of stack
  123.       tib_ptib2         : PTIB2;  -- Pointer to system specific TIB
  124.       tib_version       : ULONG;  -- Version number for this TIB structure
  125.       tib_ordinal       : ULONG;  -- Thread ordinal number
  126.    end record;
  127.  
  128.    type PTIB is access all TIB;
  129.  
  130.    --  Process Information Block (PIB)
  131.  
  132.    type PIB is record
  133.       pib_ulpid         : ULONG;   -- Process I.D.
  134.       pib_ulppid        : ULONG;   -- Parent process I.D.
  135.       pib_hmte          : ULONG;   -- Program (.EXE) module handle
  136.       pib_pchcmd        : PCHAR;   -- Command line pointer
  137.       pib_pchenv        : PCHAR;   -- Environment pointer
  138.       pib_flstatus      : ULONG;   -- Process' status bits
  139.       pib_ultype        : ULONG;   -- Process' type code
  140.    end record;
  141.  
  142.    type PPIB is access all PIB;
  143.  
  144.    function DosGetInfoBlocks
  145.      (Pptib : access PTIB;
  146.       Pppib : access PPIB)
  147.       return  APIRET;
  148.    pragma Import (C, DosGetInfoBlocks, "DosGetInfoBlocks");
  149.  
  150.    -----------------
  151.    --  Priorities --
  152.    -----------------
  153.  
  154.    function DosSetPriority
  155.      (Scope   : ULONG;
  156.       Class   : ULONG;
  157.       Delta_P : IC.long;
  158.       PorTid  : TID)
  159.       return    APIRET;
  160.    pragma Import (C, DosSetPriority, "DosSetPriority");
  161.  
  162.    PRTYS_PROCESS     : constant := 0;
  163.    PRTYS_PROCESSTREE : constant := 1;
  164.    PRTYS_THREAD      : constant := 2;
  165.    --  Values for "Scope" parameter in DosSetPriority call
  166.  
  167.    PRTYC_NOCHANGE         : constant := 0;
  168.    PRTYC_IDLETIME         : constant := 1;
  169.    PRTYC_REGULAR          : constant := 2;
  170.    PRTYC_TIMECRITICAL     : constant := 3;
  171.    PRTYC_FOREGROUNDSERVER : constant := 4;
  172.    --  Values for "class" parameter in DosSetPriority call
  173.  
  174. end Interfaces.OS2Lib.Threads;
  175.